/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TurnPanel.java
 *
 * Created on 26/07/2011, 8:59:54 PM
 */
package deatax.display.gui;

import deatax.Player;
import deatax.state.GameState;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author Pieman
 */
public class TurnPanel extends RoundedPanel {

    GameState state = null;
    /** Creates new form TurnPanel */
    public TurnPanel(GameState state) {
        initComponents();
        this.state = state;
        btnEndTurn.addActionListener(new FinishListener());
    }
    
    public void setCurrentPlayer(Player p) {
        lblName.setForeground(p.getColor());
        lblName.setText(p.getName() + "'s Turn");
    }
    
    public void setEndEnabled(boolean b) {
        btnEndTurn.setEnabled(b);
    }
    
    private class FinishListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (state != null) {
                state.finish();
            }
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblName = new javax.swing.JLabel();
        btnEndTurn = new javax.swing.JButton();

        lblName.setFont(lblName.getFont().deriveFont(lblName.getFont().getStyle() | java.awt.Font.BOLD, lblName.getFont().getSize()+4));
        lblName.setText("Name");

        btnEndTurn.setFont(btnEndTurn.getFont().deriveFont(btnEndTurn.getFont().getStyle() | java.awt.Font.BOLD, btnEndTurn.getFont().getSize()+4));
        btnEndTurn.setText("End Turn");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
                    .addComponent(btnEndTurn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEndTurn, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnEndTurn;
    private javax.swing.JLabel lblName;
    // End of variables declaration//GEN-END:variables
}
